package com.sise.wangzhan.restlet;

import org.restlet.data.MediaType;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @Classname RestletClient
 * @Description TODO
 * @Date 2020/4/8 20:47
 * @Created by wangzhan
 */
public class RestletClient {
    public static void main(String[] args) throws IOException {

        ClientResource client = new ClientResource(
                "http://localhost:8080/person/1");
        Representation response = client.get(MediaType.APPLICATION_JSON);
        JacksonRepresentation jr = new JacksonRepresentation(response, HashMap.class);

        Map result = (HashMap) jr.getObject();
        System.out.println(result.get("person_id")+"-"+result.get("p_name")+"-"
        +result.get("age")+"-"+result.get("message"));

    }
}
